<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改</title>
    <link rel="stylesheet" type="text/css" href="/static/css/base.css">
    <link rel="stylesheet" type="text/css" href="/static/easyui/uimaker/easyui.css">
    <link rel="stylesheet" type="text/css" href="/static/easyui/uimaker/icon.css">
    <link rel="stylesheet" type="text/css" href="/static/css/edit.css">
    <link rel="stylesheet" type="text/css" href="/static/webuploader/webuploader.css">

    <script type="text/javascript" src="/static/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/static/easyui/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/static/js/calendar.js"></script>
    <script type="text/javascript" src="/static/webuploader/webuploader.js"></script>
</head>
<body>
<div class="container">
    <div class="content">
        <div title="修改" data-options="closable:false" class="basic-info">
            <div class="column"><span class="current">查看任务详情</span></div>
            <form id="ff">
                <table class="kv-table">
                    <tbody>
                    <tr>
                        <td class="kv-label">任务名称</td>
                        <td class="kv-content">
                            <input type="text" name="name" id="name" readonly="readonly">
                        </td>
                        <td class="kv-label">相关人物</td>
                        <td class="kv-content">
                            <input type="text" name="user" id="user" readonly="readonly">
                        </td>
                    </tr>
                    <tr>
                        <td class="kv-label">类型</td>
                        <td class="kv-content">
                            <input type="text" name="type" id="type" readonly="readonly">
                        </td>
                        <td class="kv-label">描述</td>
                        <td class="kv-content"><input type="text" name="description" id="description"
                                                      readonly="readonly">
                        </td>
                    </tr>
                    <tr>
                        <td class="kv-label">进度</td>
                        <td class="kv-content">
                            <input type="text" name="rate" id="rate" readonly="readonly">
                        </td>
                        </td>
                        <td class="kv-label">次数</td>
                        <td class="kv-content">
                            <input type="text" name="numberTimes" id="numberTimes"
                                   class="easyui-validatebox" readonly="readonly">
                        </td>
                    </tr>
                    <tr>
                        <td class="kv-label">备注</td>
                        <td class="kv-content">
                            <input type="text" name="remark" id="remark" readonly="readonly">
                        </td>
                        <td class="kv-label">优先级</td>
                        <td class="kv-content">
                            <input type="text" name="priorityLevel" id="priorityLevel" readonly="readonly">
                        </td>
                    </tr>
                    <tr>
                        <td class="kv-label">用户名</td>
                        <td class="kv-content">
                            <input type="text" name="username" id="username" readonly="readonly">
                        </td>

                        <td class="kv-label">封面照片</td>
                        <td class="kv-content">
                            <a href="javascript:lookPic()">点击查看</a>
                            <input type="hidden" name="pic" id="pic"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>
<div id="currentWindow"></div>
<script type="text/javascript">
    // 创建 URLSearchParams 对象并传入当前页面的 URL
    const params = new URLSearchParams(window.location.search);
    // 通过 get() 方法获取指定参数名称的值
    const id = params.get('id'); // 'paramName'为要获取的参数名称
    $(function () {
        // 从数据库中获取当前ID的详情
        $.ajax({
            method: "get",
            url: "/home/progress/get?id=" + id,
            contentType: "application/json",
            type: "json",
            success: function (response) {
                if (response.code === 200) {
                    let obj = response.data;
                    $("#name").val(obj.name);
                    if (obj.user != null) {
                        $("#user").val(obj.user.join(","))
                    }
                    $("#type").val(obj.type);
                    $("#description").val(obj.description);
                    $("#rate").val(obj.rate);
                    $("#numberTimes").val(obj.numberTimes);
                    $("#username").val(obj.username);
                    $("#priorityLevel").val(obj.priorityLevel);
                    $("#pic").val(obj.pic);
                    $("#remark").val(obj.remark);
                }
            },
            error: function (err) {

            }
        })
    });

    function lookPic() {
        let fileName = $("#pic").val()
        let options = {
            width : 550,
            height : 400,
            title : "查看封面",
            url : "/manage/showImage.html?fileName=" + fileName
        }
        openTopWindow(options);
    }

    function openTopWindow(options) {
        options = !options ? {} : options;
        options.width = !options.width ? 500 : options.width;
        options.height = !options.height ? 400 : options.height;
        options.url = !options.url ? "404.html" : options.url;
        options.title = !options.title ? "" : options.title;
        // 子页面调用父页面的函数
        $("#currentWindow").window({
            title: options.title,
            width: options.width,
            height: options.height,
            content: "<iframe scrolling='no' frameborder='0' border='0' height='100%' width='100%' src='" + options.url + "'></iframe>",
            modal: true,
            resizable: false,
            collapsible: false
        });
    }
</script>
</body>
</html>